package com.firstresponder.location;

import android.location.Location;
import android.util.Log;
/**
 * Class which computes the distance between current location and current destination.
 * 
 * If necessary, could be substituted with another algorithm using time to destination
 * instead of distance to destination (thus the name of the class - Nearness Calculator).
 * 
 * @author Gergana Stoykova
 *
 */
public class NearnessCalculator {
	
	private static final String TAG = "DistanceCalculator";
	
	/**
	 *  Uses built in "distanceToDestination" method to compute distance between
	 *  current location and current destination via a straight line
	 * 
	 * @param myLat - current latitude of current location
	 * @param myLon - current longitude of current location
	 * @param destLat - current latitude of current destination 
	 * @param destLon - current longitude of current destination
	 * @return array of floats whose last element contains distances between these two
	 */
	public static float distanceToDestination(double myLat, double myLon, 
			double destLat, double destLon){
		Log.d(TAG, "in distanceToDestination method");
	
		float[] dist = new float[2]; 
		Location.distanceBetween(myLat, myLon, destLat, destLon, dist);	
		String s = new Float(dist[0]).toString();
		Log.d(TAG, s);
		return dist[0];
		
	}
	

}
